Skip to content

Development Updates#82

Merged
denehoffman merged 7 commits intomainfrom
development
Sep 26, 2025
Merged

Development Updates#82
denehoffman merged 7 commits intomainfrom
development

Conversation

@denehoffman
Copy link
Copy Markdown
Owner

@denehoffman denehoffman commented Sep 23, 2025

This pull request introduces several improvements and refactorings to the configuration and trait implementations for optimization algorithms in the codebase. The main changes include the addition of new builder methods for setting multiple parameters at once, enhanced parameter validation, expanded unit testing for configuration methods, and trait updates to improve thread safety and composability.

Configuration builder and validation improvements

  • Added new methods to set multiple related parameters simultaneously for NelderMeadConfig (with_alpha_beta), HagerZhangLineSearch (with_delta_sigma), and MoreThuenteLineSearch (with_c1_c2), with strict validation and documentation for panics on invalid input. [1] [2] [3]
  • Changed several builder methods in Swarm to consume and return Self instead of using mutable references, improving ergonomics and composability for swarm configuration.

Expanded unit test coverage

  • Added comprehensive tests for all new and existing configuration builder methods in BacktrackingLineSearch, HagerZhangLineSearch, and MoreThuenteLineSearch, including checks for correct value assignment and expected panics on invalid input. [1] [2] [3] [4]

Trait enhancements for thread safety

  • Updated core traits (AbortSignal, Algorithm, BoundLike, LineSearch, and Transform) to require Send and Sync, ensuring that algorithm components are safe for concurrent and multi-threaded execution. [1] [2] [3] [4] [5]

Documentation and minor algorithmic clarifications

  • Improved documentation for simplex initialization in Nelder-Mead and clarified comments for parameter validation logic in line search algorithms. [1] [2] [3]

Minor refactoring

  • Simplified Bound conversion logic for (Option<Float>, Option<Float>), removing unnecessary ordering and directly mapping to bound variants.
  • Minor wording and comment changes for clarity in SwarmStatus and other modules.

Let me know if you'd like a deeper dive into any of these changes or want to discuss how the new builder methods and trait bounds affect usage patterns!This pull request introduces new convenience methods to set multiple related parameters at once in several optimization algorithm configuration structs, clarifies documentation and panic conditions, and improves thread safety and API consistency across traits and structs. The most significant changes are grouped below.

New convenience methods for configuration

  • Added with_alpha_beta to NelderMeadConfig to set both the reflection and expansion coefficients simultaneously, with appropriate assertions.
  • Added with_delta_sigma to HagerZhangLineSearch to set both Armijo and Wolfe condition parameters at once, with validation.
  • Added with_c1_c2 to MoreThuenteLineSearch to set both control parameters for Armijo and Wolfe conditions simultaneously, with validation.

API consistency and ergonomics

  • Updated several methods in Swarm to take and return Self by value instead of mutable references, improving method chaining and consistency.

Thread safety improvements

  • Added Send + Sync bounds to core traits such as AbortSignal, Algorithm, BoundLike, LineSearch, and Transform, ensuring these types can be safely shared across threads. [1] [2] [3] [4] [5]

Documentation and validation clarity

  • Improved documentation and panic condition descriptions for parameter-setting methods in HagerZhangLineSearch and MoreThuenteLineSearch to accurately reflect the mathematical requirements. [1] [2]
  • Clarified simplex initialization in the Nelder-Mead algorithm documentation.

Minor improvements

  • Simplified SwarmStatus field documentation for clarity.
  • Refactored From<(Option<Float>, Option<Float>)> for Bound for clarity and correctness in bound construction.

…d on each other

This lets us set two parameters like alpha and beta without worrying about an assert panic. For example, if we require alpha < beta and beta defaults to 0.9, then we cannot set alpha to 0.91 even if we plan on later setting beta to 0.95. Rather than check if alpha > beta's default and branching, we can just set them both at the same time.
These should match the mut self -> Self pattern we use everywhere else
This makes Box<dyn T>'s easier to work with in multithreaded environments
…d unbounded intervals

Previously, converting (Some(Float::NEG_INFINITY), Some(Float::INFINITY)) to a Bound with Into would create a Bound::LowerAndUpperBound, which is not correct and could cause issues in transforms. This also makes it okay for users to mix and match Nones and infinities.
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 23, 2025

Codecov Report

❌ Patch coverage is 94.47514% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.10%. Comparing base (90f145e) to head (a4de0ff).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/algorithms/particles/swarm.rs 0.00% 5 Missing ⚠️
src/traits/boundlike.rs 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #82      +/-   ##
==========================================
+ Coverage   86.94%   88.10%   +1.15%     
==========================================
  Files          32       32              
  Lines        5969     6137     +168     
==========================================
+ Hits         5190     5407     +217     
+ Misses        779      730      -49     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Sep 23, 2025

CodSpeed Performance Report

Merging #82 will not alter performance

Comparing development (a4de0ff) with main (90f145e)

Summary

✅ 18 untouched

While this line search is currently unused by the provided algorithms, these are useful to have in the event someone wants to build an algorithm which uses it.
@denehoffman denehoffman changed the title Dvevelopment Updates Development Updates Sep 26, 2025
@denehoffman denehoffman merged commit 873f421 into main Sep 26, 2025
10 checks passed
@denehoffman denehoffman deleted the development branch September 26, 2025 21:21
@github-actions github-actions bot mentioned this pull request Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant